package com.wwg;

import java.util.Random;

public class Test {

    private static int MAX_COUNT= 5;//客户人数

    public static void main(String[] args) throws CloneNotSupportedException {

        int i = 0;
        Mail mail = new Mail(new AdvTemplate());
        mail.setTail("中国工商银行版权所有 ");

        while (i < MAX_COUNT) {

            Mail cloneMail = (Mail) mail.clone();
            cloneMail.setAppellation(getRandString(5) + "先生（女士）");
            cloneMail.setReceive(getRandString(8) + "@" +getRandString(5) + ".com");
            sendMail(cloneMail);
            i++;
        }

    }

    public static void sendMail(Mail mail){

        System.out.println("标题：" + mail.getSubject() + "\t收件人：" + mail.getReceive() + "\t...发送成功！");
    }


    public static String getRandString(int maxLength) {

        String source = "qwertyuiopasdfghjklzxcvbnm";
        StringBuffer sb = new StringBuffer();
        Random rd = new Random();

        for(int i=0; i<maxLength; i++) {
            sb.append(source.charAt(rd.nextInt(source.length())));
        }

        return sb.toString();
    }
}
